<template>
  <div>
    <!-- 碎片列表 -->
    <my-breadcrumb :items="['用户管理', '拉黑列表']"/>
    <search :formItems='searchItems' @search='getList' ref='search' />
    <el-table :data='tableData' style='width: 100%'>
      <el-table-column type="index" label='序号' ></el-table-column>
      <el-table-column prop='membername' label='被拉黑人名称' ></el-table-column>
      <!-- <el-table-column prop='bid' label='被拉黑人id' ></el-table-column> -->
      <el-table-column prop='phone' label='被拉黑人手机'></el-table-column>
      <el-table-column prop='blackcount' label='被拉黑次数'></el-table-column>
    </el-table>
    <div class="page">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.page"
        :page-sizes="[20, 50, 100]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  name: 'black',
  data () {
    return {
      tableData: [],
      searchItems: [
        {
          label: '被拉黑人名称',
          type: 'input',
          key: 'membername',
          width: '100px'
        },
        {
          label: '被拉黑人手机',
          type: 'input',
          key: 'phone',
          width: '100px'
        }
      ],
      page: {
        page: 1,
        size: 20,
        total: 1
      }
    }
  },
  methods: {
    getList () {
      let searchData = {}
      if (this.$refs['search']) {
        searchData = this.$refs['search'].search()
      }
      let params = {
        ...searchData,
        page: this.page.page,
        size: this.page.size
      }
      this.axios.get('/Blacklist/index', { params }).then(res => {
        if (res.data.status === 1 || res.data.status === '1') {
          this.page.total = Number(res.data.data.count)
          this.tableData = res.data.data.list
        }
      })
    },
    handleSizeChange (val) {
      this.page.size = val
      this.getList()
    },
    handleCurrentChange (val) {
      this.page.page = val
      this.getList()
    }
  },
  mounted () {
    this.getList()
  }
}
</script>
<style scoped>
</style>
